import * as echarts from 'echarts';
export default {
    backgroundColor:'transparent',
       tooltip: {
         trigger: 'axis',
         axisPointer: { // 坐标轴指示器，坐标轴触发有效
           type: 'shadow' // 默认为直线，可选为：'line' | 'shadow'
         }
       },
       grid: {
         left: '2%',
         right: '4%',
         bottom: '14%',
         top:'16%',
         containLabel: true
       },
    legend: {
       data: ['新增企业', '消防企业'],
       right: 10,
        bottom: 12,
       textStyle: {
           color: "#fff"
       },
       itemWidth: 12,
       itemHeight: 10,
       // itemGap: 35
   },
       xAxis: {
         type: 'category',
         data: ['1月', '2月', '3月','4月', '5月', '6月','7月', '8月', '9月','10月', '11月', '12月'],
         axisLine: {
           lineStyle: {
             color: 'white'
           }
         },
         axisLabel: {
           // interval: 0,
           // rotate: 40,
           textStyle: {
             fontFamily: 'Microsoft YaHei'
           }
         },
       },

       yAxis: {
         type: 'value',
         max:'1200',
         axisLine: {
           show: false,
           lineStyle: {
             color: 'white'
           }
         },
         splitLine: {
           show: true,
           lineStyle: {
             color: 'rgba(255,255,255,0.3)'
           }
         },
         axisLabel: {}
       },
       series: [{
         name: '新增企业',
         type: 'bar',
         barWidth: '15%',
         itemStyle: {
           normal: {
               color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                   offset: 0,
                   color: '#fccb05'
               }, {
                   offset: 1,
                   color: '#f5804d'
               }]),
               barBorderRadius: 12,
           },
         },
         data: [400, 400, 300, 300, 300, 400, 400, 400, 300,400, 400, 300]
       },
       {
         name: '消防企业',
         type: 'bar',
         barWidth: '15%',
         itemStyle: {
           normal: {
               color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                   offset: 0,
                   color: '#8bd46e'
               }, {
                   offset: 1,
                   color: '#09bcb7'
               }]),
               barBorderRadius: 11,
           }
           
         },
         data: [400, 400, 300, 300, 300, 400, 400, 300,400,400, 500, 500]
       }]
     };

     var app = {
       currentIndex: -1,
     };
     setInterval(function () {
       var dataLen = option.series[0].data.length;

       // 取消之前高亮的图形
       myChart.dispatchAction({
         type: 'downplay',
         seriesIndex: 0,
         dataIndex: app.currentIndex
       });
       app.currentIndex = (app.currentIndex + 1) % dataLen;
       //console.log(app.currentIndex);
       // 高亮当前图形
       myChart.dispatchAction({
         type: 'highlight',
         seriesIndex: 0,
         dataIndex: app.currentIndex,
       });
       // 显示 tooltip
       myChart.dispatchAction({
         type: 'showTip',
         seriesIndex: 0,
         dataIndex: app.currentIndex
       });


     }, 1000);